<?php

include_once 'operacionesBD.php';

if(isset($_POST['SearchInput'])){
    $dataBase = new operacionesBD();
    $input = $_POST['SearchInput'];
    $query = 'Select * FROM metadata WHERE title like "%'.$input.'%"';
    $result = $dataBase->consultar($query);
    $response = '';
//    var_dump($result);
    foreach($result as $song){
        $title = $song['title'];
        $title = str_replace($input, '<span class="highlight" >'.$input.'</span>', $title);
        $response .= '<p onClick="playsongsp('.$title.')">'.$title.'</p><br>';
    }
    echo $response;
}
?>
